import React from 'react';
import BaseScreen from "../BaseScreen";
import styles from "../../css/Help.module.css"
import { getSkillDetail } from '../../service/MineService'
import { Actions, NameSpace } from "../../model/taskModel";
import { connect } from "react-redux";
import {navigateTo} from '../../utils/LocationUtil'
import { getInfo, getTOKEN } from '../../utils/StorageUtil';
import { getLocalTime } from '../../utils/CommomUtil'
import ProgressView from "../../view/ProgressView";
// import { Infoicon } from "../../const/imgs"
class NoticeDetail extends BaseScreen{
  constructor(props){
    super(props);
    this.state={
      loading:false,
      problem:{}
    }
  }
  componentDidMount(){
    document.title=  getInfo('skill').title
    const params ={
      id: getInfo('skill').id,
      token:getTOKEN()
    }
    console.log( getInfo('skillId') )
    let that = this      
      this.setState({loading:true})
      getSkillDetail(params)
    .then(res => {
      this.setState({loading:false})
      if(res.error_code === 0){
        that.setState({
          problem:res.data
        })
        var div = document.createElement("div");
        div.innerHTML = res.data.content
        this.refs.content.appendChild(div)
        that.render()
      }
    })
    .catch(err => {
      this.setState({loading:false})
      
      //console.log(err);
    });
  }
  navigate = (e)=>{
  }
  render() {
    const {problem,loading} = this.state
    return(
      <div className={styles['help_container']} >  
         {/* <div className={styles['help_title']} >  
        {problem.title}
        </div> */}
        {/* {problem.create_time&&<div className={styles['help_time']} >  
        {getLocalTime(problem.create_time,20)}
        </div>} */}
        <div className={styles['help_content']} ref='content' >  
        </div>
        <ProgressView visibility={loading} mode={ProgressView.MODE_MEDIUM} />
      </div>
    )
  }
}

const mapStateToProps = state => {
  return {
    ...state[NameSpace]
  };
};

const mapDispatchToProps = dispatch => {
  return {
    selectItem(item) {
      let params = {
        problemId: item.id,
      };
      dispatch(Actions.actionSelectProblems(params));
    },
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(NoticeDetail);